package main

import (
	"fmt"
)

func main() {
	max1 := 35
	max2 := 20
	num := 9
	a := []int{}
	for n := 1; n < max1+1; n++ {
		a = append(a, n)
	}
	fmt.Println(f1(num, max2, a))
}

func f1(num, max int, x []int) []int {
	i := 0
	y := make([]int, len(x))
	copy(y, x)
	for len(x) > max {
		for k, _ := range x {
			if (k+i) >= num-1 && (k+1+i)%num == 0 {
				//fmt.Println("x:", x, x[k])
				for j, _ := range y {
					if y[j] == x[k] {
						y = append(y[:j], y[j+1:]...)
						//fmt.Println("y:", y)
						break
					}
				}
				if len(x) == max {
					return x
				}
			}
		}
		i = (len(x) + i) % num
		x = make([]int, len(y))
		copy(x, y)
	}
	return x
}

func f2(num int, x2 []int) []int {
	y1 := make([]int, len(x2))
	copy(y1, x2)
	for k, v := range y1 {
		if y1[v] == num {
			y1 = append(y1[:k], y1[k+1:]...)
			fmt.Println(y1)
			break
		}
	}

	return y1
}
